﻿using UnityEngine;
using System.Collections;

public class ZombieScript : MonoBehaviour
{
		private Animator anim;
		private AudioSource audio;
		public float speed = 3.5f;
		public float Score;

		// Use this for initialization
		void Start ()
		{
				anim = GetComponentInChildren<Animator> ();
				audio = GetComponentInChildren<AudioSource> ();
		}
	
		// Update is called once per frame
		void FixedUpdate ()
		{
				transform.position -= Vector3.right * speed * Time.deltaTime;
		}

		void OnCollisionEnter2D (Collision2D other)
		{
				if (other.gameObject.tag == "bullet") {
						audio.Play ();	
						new WaitForSeconds (2);
						//	Destroy (gameObject);
						Destroy (other.gameObject);
						anim.SetTrigger ("death");
						CircleCollider2D collider = GetComponentInParent<CircleCollider2D> ();
						collider.isTrigger = true;
						speed = 3.0f;
				}
				if (other.gameObject.tag == "Player") {
						BoxCollider2D boxcollider = GetComponent<BoxCollider2D> ();
						Physics2D.IgnoreCollision (other.collider, boxcollider);
				}
		}


}
